CXX = g++

CXXFLAGS = -fopenmp

SRC = main.cpp

TARGET = parallel_sort

OBJ = $(SRC:.cpp=.o)

ARRAY_SIZE = 1000000
THREAD_SIZE = 4

all: $(TARGET)

$(TARGET): $(OBJ)
	$(CXX) $(CXXFLAGS) -o $(TARGET) $(OBJ)

%.o: %.cpp
	$(CXX) $(CXXFLAGS) -c $< -o $@

clean:
	rm -f $(OBJ) $(TARGET)

run: $(TARGET)
	./$(TARGET) $(ARRAY_SIZE) $(THREAD_SIZE)

run_custom: $(TARGET)
	@read -p "请输入数组大小: " array_size; \
	read -p "请输入线程个数: " thread_size; \
	./$(TARGET) $$array_size $$thread_size

auto_run: $(TARGET)
	@read -p "请输入数组大小: " array_size; \
	echo "开始自动运行:"; \
	for i in 1 2 4 8 16 32 64; do \
	    echo "正在以 $$i 线程运行:"; \
	    ./$(TARGET) $$array_size $$i; \
	done


.PHONY: all clean run run_custom
